<?php
	require_once('config.class.php');
	
	/**
	 * The config database class handles this application's
	 * MySQL connection based on the Config settings. 
	 */
	class ConfigDatabase {
		/**
		 * MySQL connection
		 */
		private $connection;
		
		/**
		 * Initializes a new instance of the ConfigDatabase class.
		 */
		public function __construct() {
			$config = new Config();
			$this->connection = mysql_connect($config->getDatabaseServerHost(), $config->getDatabaseLoginName(), $config->getDatabaseLoginPassword());
			mysql_select_db($config->getDatabaseName(), $this->connection);
		}
		
		/**
		 * Frees private memory used in this class and closes resources.
		 */
		public function __destruct() {
			mysql_close($this->connection);
		}
		
		/**
		 * Gets the MySQL connection.
		 * 
		 * @return mixed MySQL connection
		 */
		public function getConnection() {
			return $this->connection;
		}
	}